package nc;


import java.util.Scanner;

/**
 * 给你一个文本串 T ，一个非空模板串 S ，问 S 在 T 中出现了多少次
 *
 * 输入：
 * "ababab","abababab"
 * 返回值：
 * 2
 *
 */

public class nc149 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()){
            String S = in.nextLine();
            String T = in.nextLine();
//            int res=0;
//            for (int i = 0; i < T.length() - S.length() + 1; i++) {
//                String substring = T.substring(i, i + S.length());
//                if (substring.equals(S)){
//                    res++;
//                }
//            }
//            System.out.println(res);
            nc149 nc149 = new nc149();
            int kmp = nc149.kmp(S, T);
            System.out.println(kmp);
        }
    }

    public int kmp(String S, String T){
        if (T == null || S == null || S.length() < 1 || T.length() < S.length()) {
            return 0;
        }
        char[] chars = T.toCharArray();
        char[] chars1 = S.toCharArray();
        int i=0,j=0;
        int[] next = getNext(S);
        int res = 0;
        while (i<chars.length && j<chars1.length){
            if (chars[i] == chars1[j]){
                i++;
                j++;
            }else if (next[j] == -1){
                i++;
            }else {
                j = next[j];
            }

            if (j == chars1.length){
                res++;
                j = next[j];
            }
        }
        return res;
    }

    private int[] getNext(String S){
        if (S.length() == 1){
            return new int[]{-1};
        }
        int[] next = new int[S.length()+1];
        next[0] = -1;
        next[1] = 0;
        int i=2,cn=0;
        while (i<=S.length()){
            if (S.charAt(i-1) == S.charAt(cn)){
                next[i++] = ++cn;
            }else if (cn > 0){
                cn = next[cn];
            }else {
                next[i++] = 0;
            }
        }
        return next;
    }







}
